/**
 * 
 */
package com.java.test.messagecenter.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

/**
 * @author Administrator 跑马灯公告
 */
public class HorseNoticeInfo implements RowMapper<HorseNoticeInfo> {

	// 主键id
	private Long id;

	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime startTime;

	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime endTime;

	// 1:所有人，2：登陆 ；3：未登录
	private int powerType;

	// 内容
	private String content;


	// 1：未开始 ，2：进行中，3：已结束
	private int status;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public LocalDateTime getStartTime() {
		return startTime;
	}

	public void setStartTime(LocalDateTime startTime) {
		this.startTime = startTime;
	}

	public LocalDateTime getEndTime() {
		return endTime;
	}

	public void setEndTime(LocalDateTime endTime) {
		this.endTime = endTime;
	}

	public int getPowerType() {
		return powerType;
	}

	public void setPowerType(int powerType) {
		this.powerType = powerType;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}



	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	@Override
	public HorseNoticeInfo mapRow(ResultSet rs, int rowNum) throws SQLException {

		HorseNoticeInfo info = new HorseNoticeInfo();

		info.setId(rs.getLong("id"));
		info.setPowerType(rs.getInt("power_type"));
		info.setStartTime(rs.getTimestamp("start_time") == null ? null
				: rs.getTimestamp("start_time").toInstant().atZone(ZoneOffset.ofHours(8)).toLocalDateTime());
		info.setEndTime(rs.getTimestamp("end_time") == null ? null
				: rs.getTimestamp("end_time").toInstant().atZone(ZoneOffset.ofHours(8)).toLocalDateTime());
		info.setContent(rs.getString("content"));
		info.setStatus(rs.getInt("status"));

		return info;
	}

}
